import requests

class EmpManageApi(object):
    def add_emp(self, req_head, req_data):
        resp = requests.post(url="http://ihrm2-test.itheima.net/api/sys/user/",
                             headers=req_head, json=req_data)
        return resp

    def query_emp(self, emp_id, req_head):
        resp = requests.get(url="http://ihrm2-test.itheima.net/api/sys/user/" + emp_id,
                            headers=req_head)
        return resp

    def modify_emp(self, emp_id, req_head, req_data):
        resp = requests.put(url="http://ihrm2-test.itheima.net/api/sys/user/" + emp_id,
                            headers=req_head, json=req_data)
        return resp

    def del_emp(self, emp_id, req_head):
        resp = requests.delete(url="http://ihrm2-test.itheima.net/api/sys/user/" + emp_id,
                               headers=req_head)
        return resp


if __name__ == '__main__':
    emp = EmpManageApi()
    # 添加员工
    req_head = {"Content-Type": "application/json", "Authorization": "9e96faef-77bb-4580-94d7-8ef589a06348"}
    req_body = {"username": "jack123", "mobile": "13858137325", "workNumber": "666"}
    # 添加员工
    ret = emp.add_emp(req_head, req_body)
    print(ret.json())

    # 删除员工
    emp_id = 1570682904583876608
    del_req_head = {"Authorization": "9e96faef-77bb-4580-94d7-8ef589a06348"}
    # 删除员工
    ret = emp.query_emp(emp_id, del_req_head)
    # print(ret.json())
